package cn.tedu.zhwy.community.controller;

import cn.tedu.zhwy.base.response.JsonResult;
import cn.tedu.zhwy.community.pojo.dto.RepairsQuery;
import cn.tedu.zhwy.community.pojo.vo.RepairsVO;
import cn.tedu.zhwy.community.service.CommunityService;
import cn.tedu.zhwy.workspase.pojo.dto.LandlordParam;
import cn.tedu.zhwy.workspase.pojo.vo.LamdlordVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/v1/community")
public class CommunityController {
    @Autowired
    CommunityService communityService;
    @GetMapping("selectlist")
    public JsonResult selectList(RepairsQuery repairsQuery){
        log.debug("查询报修",repairsQuery);
        List<RepairsVO> list = communityService.selectList(repairsQuery);
        return JsonResult.ok(list);
    }
    @PostMapping("add")
    public JsonResult add(RepairsQuery repairsQuery){
        log.debug("添加报修-{}",repairsQuery);
        communityService.add(repairsQuery);
        return JsonResult.ok();
    }
    @PostMapping("delete/{rid}")
    public JsonResult delete(@PathVariable("rid") Integer rid){
        log.debug("删除报修",rid);
        communityService.delete(rid);
        return JsonResult.ok();
    }
    @PostMapping("update/{rid}")
    public JsonResult update(@PathVariable("rid") Integer rid){
        log.debug("修改报修",rid);
        communityService.update(rid);
        return JsonResult.ok();
    }
}
